home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12292 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie: How to put a byte to a000:0001 or more?
  5. Date: 29 Mar 1996 21:47:26 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4jihteINNodr@keats.ugrad.cs.ubc.ca>
  8. References: <4jhur8$995@sanjuan.islandnet.com>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4jhur8$995@sanjuan.islandnet.com>,
  12. Abram Hindle  <abehind@islandnet.com> wrote:
  13. >Ok I'm a newbie to C and to Assembler.
  14. > I need help with finding out how in assembler or in c
  15. >I can put (quickly) a byte in the a000:0000+ address to
  16. >draw a pixel on the screen?
  17.  
  18. The ':' character is used in the C language to introduce the width of a bit
  19. field:
  20.  
  21.     struct foo {
  22.         unsigned x : 3;
  23.         y : 4;
  24.     };
  25.  
  26.  
  27. >I'm doing this on a IBM compatiable in VGA mode (13h)
  28. >I've done something like so:
  29. >void putpixel(int x, int y, char col)
  30. >{
  31. >unsigned int pos;
  32. >pos=x+(y*319)
  33.  
  34. Surely you mean 320! Duh!
  35.  
  36. 319 is the product of two primes, 11 and 29. Not a likely candidate for the
  37. number of pixels in a scanline.
  38.  
  39. >asm {
  40. >
  41. >    mov al,[col]/*al = colour*/
  42. >    mov ax,[pos]/*ax = position*/
  43.  
  44. Duh, a move to ax clobbers al. The ax register is made up of ah and al.
  45.  
  46. Please don't post obsolete 16-bit assembly code to a newsgroup that
  47. doesn't even have anything to do with assembly language programming!
  48.  
  49. It is annoying.
  50.  
  51. >    mov DI,ax /*move ax to di*/
  52. >    mov ax,[VGA]/*copies 0a000h to ax i've defined it*/
  53.  
  54. That is a redundant instruction that even a Microsoft C++ compiler would
  55. eliminate. You first move something to ax, and then you move from ax to
  56. something else, and then you clobber ax again, meaning that the original move
  57. to ax was completely useless.
  58.  
  59. >    mov es,ax /*moves that to es*/
  60. >    mov [ES:DI],al  /*Put in Memory al(colour)*/
  61.  
  62. The color in al that you clobbered in line 2?
  63.  
  64.  
  65. >    }
  66. >}
  67. >
  68. >and it does nothing! So could you guys help? I really need it,
  69.  
  70. Go to comp.lang.asm.x86. This is a C language newsgroup.
  71.  
  72. >BGIs are to slow and so is using int 10h.
  73.  
  74. How would you know?
  75. -- 
  76.  
  77.